<?php
//header('Content-Type: text/html; charset=utf-8');
require("class.phpmailer.php");
//error_reporting(E_ERROR);

// 配置数组 config array
// $arr=array(
// 	'to'=>array('123@baidu.com','456@qq.com'),
// 	'bcc'=>array('123@baidu.com','456@qq.com'),
// 	'subject'=>'This is a test.',
// 	'body'=>'As you know',
// 	'host'=>'smtp.163.com',
// 	'account'=>'ecomgear@163.com',
// 	'password'=>'youguess',
// 	'port'=>'25',
// 	'name'=>'eComGear',
// 	);
function mail_send($config){
	if(! isset($config['port'])) $config['port']= 25;
	if(! isset($config['name'])) $config['name']= 'eComGear/WebCEO';
	$mail = new PHPMailer();
	$mail->IsSMTP();
	if(isset($config['ssl'])&&$config['ssl']==1) {
		$mail->SMTPSecure = "ssl";
	}
	$mail->Host = $config['host'];
	$mail->Username = $config['account'];
	$mail->Password = $config['password'];
	// Port of the SMTP Server
	$mail->Port = $config['port'];
	$mail->FromName = $config['name'];
	$mail->SMTPAuth = true;
	// sets the prefix to the servier
	//$mail->SMTPSecure = "TSL";
	$mail->From = $mail->Username;
	$mail->CharSet = "UTF-8";
	$mail->Encoding = "base64";
	foreach($config['to'] as $m){ $mail->AddAddress($m); }
	foreach($config['bcc'] as $m){ $mail->AddBCC($m); }
	//foreach($att as $key=>$val){
	//	if(!empty($val)){
	//		$mail->AddAttachment($val);  //注意要给绝对路径
	//	}
	//}
	$mail->IsHTML(true); 
	$mail->Subject = $config['subject'];
	$mail->Body = $config['body'];
	$mail->AltBody ="text/html"; 
	if($mail->Send()) return true;
	else return false;
}

// end of file
